﻿namespace Contoso.ActiveDirectory {

    #region Usings
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks; 
    #endregion

    [Serializable]
    public class ExchangeExtensionAttributes : IExchangeExtensionAttributes {

        #region Members
        public static readonly string[] AttributesToGet;

        public string ExtensionAttribute1 { get; private set; }
        public string ExtensionAttribute2 { get; private set; }
        public string ExtensionAttribute3 { get; private set; }
        public string ExtensionAttribute4 { get; private set; }
        public string ExtensionAttribute5 { get; private set; }
        public string ExtensionAttribute6 { get; private set; }
        public string ExtensionAttribute7 { get; private set; }
        public string ExtensionAttribute8 { get; private set; }
        public string ExtensionAttribute9 { get; private set; }
        public string ExtensionAttribute10 { get; private set; }
        public string ExtensionAttribute11 { get; private set; }
        public string ExtensionAttribute12 { get; private set; }
        public string ExtensionAttribute13 { get; private set; }
        public string ExtensionAttribute14 { get; private set; }
        public string ExtensionAttribute15 { get; private set; }

        public string MSExchExtensionAttribute16 { get; private set; }
        public string MSExchExtensionAttribute17 { get; private set; }
        public string MSExchExtensionAttribute18 { get; private set; }
        public string MSExchExtensionAttribute19 { get; private set; }
        public string MSExchExtensionAttribute20 { get; private set; }
        public string MSExchExtensionAttribute21 { get; private set; }
        public string MSExchExtensionAttribute22 { get; private set; }
        public string MSExchExtensionAttribute23 { get; private set; }
        public string MSExchExtensionAttribute24 { get; private set; }
        public string MSExchExtensionAttribute25 { get; private set; }
        public string MSExchExtensionAttribute26 { get; private set; }
        public string MSExchExtensionAttribute27 { get; private set; }
        public string MSExchExtensionAttribute28 { get; private set; }
        public string MSExchExtensionAttribute29 { get; private set; }
        public string MSExchExtensionAttribute30 { get; private set; }
        public string MSExchExtensionAttribute31 { get; private set; }
        public string MSExchExtensionAttribute32 { get; private set; }
        public string MSExchExtensionAttribute33 { get; private set; }
        public string MSExchExtensionAttribute34 { get; private set; }
        public string MSExchExtensionAttribute35 { get; private set; }
        public string MSExchExtensionAttribute36 { get; private set; }
        public string MSExchExtensionAttribute37 { get; private set; }
        public string MSExchExtensionAttribute38 { get; private set; }
        public string MSExchExtensionAttribute39 { get; private set; }
        public string MSExchExtensionAttribute40 { get; private set; }
        public string MSExchExtensionAttribute41 { get; private set; }
        public string MSExchExtensionAttribute42 { get; private set; }
        public string MSExchExtensionAttribute43 { get; private set; }
        public string MSExchExtensionAttribute44 { get; private set; }
        public string MSExchExtensionAttribute45 { get; private set; }

        public IReadOnlyList<string> MSExchExtensionCustomAttribute1 { get; private set; }
        public IReadOnlyList<string> MSExchExtensionCustomAttribute2 { get; private set; }
        public IReadOnlyList<string> MSExchExtensionCustomAttribute3 { get; private set; }
        public IReadOnlyList<string> MSExchExtensionCustomAttribute4 { get; private set; }
        public IReadOnlyList<string> MSExchExtensionCustomAttribute5 { get; private set; }
        #endregion

        #region Constructors
        static ExchangeExtensionAttributes() {
            AttributesToGet = new string[]
            {
                "extensionAttribute1",
                "extensionAttribute2",
                "extensionAttribute3",
                "extensionAttribute4",
                "extensionAttribute5",
                "extensionAttribute6",
                "extensionAttribute7",
                "extensionAttribute8",
                "extensionAttribute9",
                "extensionAttribute10",
                "extensionAttribute11",
                "extensionAttribute12",
                "extensionAttribute13",
                "extensionAttribute14",
                "extensionAttribute15",
                "msExchExtensionAttribute16",
                "msExchExtensionAttribute17",
                "msExchExtensionAttribute18",
                "msExchExtensionAttribute19",
                "msExchExtensionAttribute20",
                "msExchExtensionAttribute21",
                "msExchExtensionAttribute22",
                "msExchExtensionAttribute23",
                "msExchExtensionAttribute24",
                "msExchExtensionAttribute25",
                "msExchExtensionAttribute26",
                "msExchExtensionAttribute27",
                "msExchExtensionAttribute28",
                "msExchExtensionAttribute29",
                "msExchExtensionAttribute30",
                "msExchExtensionAttribute31",
                "msExchExtensionAttribute32",
                "msExchExtensionAttribute33",
                "msExchExtensionAttribute34",
                "msExchExtensionAttribute35",
                "msExchExtensionAttribute36",
                "msExchExtensionAttribute37",
                "msExchExtensionAttribute38",
                "msExchExtensionAttribute39",
                "msExchExtensionAttribute40",
                "msExchExtensionAttribute41",
                "msExchExtensionAttribute42",
                "msExchExtensionAttribute43",
                "msExchExtensionAttribute44",
                "msExchExtensionAttribute45",
                "msExchExtensionCustomAttribute1",
                "msExchExtensionCustomAttribute2",
                "msExchExtensionCustomAttribute3",
                "msExchExtensionCustomAttribute4",
                "msExchExtensionCustomAttribute5"
            };
        }
        public ExchangeExtensionAttributes() {
            this.ExtensionAttribute1 = string.Empty;
            this.ExtensionAttribute2 = string.Empty;
            this.ExtensionAttribute3 = string.Empty;
            this.ExtensionAttribute4 = string.Empty;
            this.ExtensionAttribute5 = string.Empty;
            this.ExtensionAttribute6 = string.Empty;
            this.ExtensionAttribute7 = string.Empty;
            this.ExtensionAttribute8 = string.Empty;
            this.ExtensionAttribute9 = string.Empty;
            this.ExtensionAttribute10 = string.Empty;
            this.ExtensionAttribute11 = string.Empty;
            this.ExtensionAttribute12 = string.Empty;
            this.ExtensionAttribute13 = string.Empty;
            this.ExtensionAttribute14 = string.Empty;
            this.ExtensionAttribute15 = string.Empty;

            this.MSExchExtensionAttribute16 = string.Empty;
            this.MSExchExtensionAttribute17 = string.Empty;
            this.MSExchExtensionAttribute18 = string.Empty;
            this.MSExchExtensionAttribute19 = string.Empty;
            this.MSExchExtensionAttribute20 = string.Empty;
            this.MSExchExtensionAttribute21 = string.Empty;
            this.MSExchExtensionAttribute22 = string.Empty;
            this.MSExchExtensionAttribute23 = string.Empty;
            this.MSExchExtensionAttribute24 = string.Empty;
            this.MSExchExtensionAttribute25 = string.Empty;
            this.MSExchExtensionAttribute26 = string.Empty;
            this.MSExchExtensionAttribute27 = string.Empty;
            this.MSExchExtensionAttribute28 = string.Empty;
            this.MSExchExtensionAttribute29 = string.Empty;
            this.MSExchExtensionAttribute30 = string.Empty;
            this.MSExchExtensionAttribute31 = string.Empty;
            this.MSExchExtensionAttribute32 = string.Empty;
            this.MSExchExtensionAttribute33 = string.Empty;
            this.MSExchExtensionAttribute34 = string.Empty;
            this.MSExchExtensionAttribute35 = string.Empty;
            this.MSExchExtensionAttribute36 = string.Empty;
            this.MSExchExtensionAttribute37 = string.Empty;
            this.MSExchExtensionAttribute38 = string.Empty;
            this.MSExchExtensionAttribute39 = string.Empty;
            this.MSExchExtensionAttribute40 = string.Empty;
            this.MSExchExtensionAttribute41 = string.Empty;
            this.MSExchExtensionAttribute42 = string.Empty;
            this.MSExchExtensionAttribute43 = string.Empty;
            this.MSExchExtensionAttribute44 = string.Empty;
            this.MSExchExtensionAttribute45 = string.Empty;

            this.MSExchExtensionCustomAttribute1 = new List<string>();
            this.MSExchExtensionCustomAttribute2 = new List<string>();
            this.MSExchExtensionCustomAttribute3 = new List<string>();
            this.MSExchExtensionCustomAttribute4 = new List<string>();
            this.MSExchExtensionCustomAttribute5 = new List<string>();
        } 
        #endregion

        #region Methods
        public void ProcessResults(Dictionary<string, object[]> attributes) {
            if (attributes.ContainsKey("extensionAttribute1")) {
                this.ExtensionAttribute1 = attributes["extensionAttribute1"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute2")) {
                this.ExtensionAttribute2 = attributes["extensionAttribute2"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute3")) {
                this.ExtensionAttribute3 = attributes["extensionAttribute3"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute4")) {
                this.ExtensionAttribute4 = attributes["extensionAttribute4"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute5")) {
                this.ExtensionAttribute5 = attributes["extensionAttribute5"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute6")) {
                this.ExtensionAttribute6 = attributes["extensionAttribute6"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute7")) {
                this.ExtensionAttribute7 = attributes["extensionAttribute7"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute8")) {
                this.ExtensionAttribute8 = attributes["extensionAttribute8"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute9")) {
                this.ExtensionAttribute9 = attributes["extensionAttribute9"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute10")) {
                this.ExtensionAttribute10 = attributes["extensionAttribute10"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute11")) {
                this.ExtensionAttribute11 = attributes["extensionAttribute11"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute12")) {
                this.ExtensionAttribute12 = attributes["extensionAttribute12"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute13")) {
                this.ExtensionAttribute13 = attributes["extensionAttribute13"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute14")) {
                this.ExtensionAttribute14 = attributes["extensionAttribute14"][0].ToString();
            }
            if (attributes.ContainsKey("extensionAttribute15")) {
                this.ExtensionAttribute15 = attributes["extensionAttribute15"][0].ToString();
            }

            if (attributes.ContainsKey("msExchExtensionAttribute16")) {
                this.MSExchExtensionAttribute16 = attributes["msExchExtensionAttribute16"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute17")) {
                this.MSExchExtensionAttribute17 = attributes["msExchExtensionAttribute17"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute18")) {
                this.MSExchExtensionAttribute18 = attributes["msExchExtensionAttribute18"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute19")) {
                this.MSExchExtensionAttribute19 = attributes["msExchExtensionAttribute19"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute20")) {
                this.MSExchExtensionAttribute20 = attributes["msExchExtensionAttribute20"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute21")) {
                this.MSExchExtensionAttribute21 = attributes["msExchExtensionAttribute21"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute22")) {
                this.MSExchExtensionAttribute22 = attributes["msExchExtensionAttribute22"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute23")) {
                this.MSExchExtensionAttribute23 = attributes["msExchExtensionAttribute23"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute24")) {
                this.MSExchExtensionAttribute24 = attributes["msExchExtensionAttribute24"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute25")) {
                this.MSExchExtensionAttribute25 = attributes["msExchExtensionAttribute25"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute26")) {
                this.MSExchExtensionAttribute26 = attributes["msExchExtensionAttribute26"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute27")) {
                this.MSExchExtensionAttribute27 = attributes["msExchExtensionAttribute27"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute28")) {
                this.MSExchExtensionAttribute28 = attributes["msExchExtensionAttribute28"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute29")) {
                this.MSExchExtensionAttribute29 = attributes["msExchExtensionAttribute29"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute30")) {
                this.MSExchExtensionAttribute30 = attributes["msExchExtensionAttribute30"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute31")) {
                this.MSExchExtensionAttribute31 = attributes["msExchExtensionAttribute31"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute32")) {
                this.MSExchExtensionAttribute32 = attributes["msExchExtensionAttribute32"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute33")) {
                this.MSExchExtensionAttribute33 = attributes["msExchExtensionAttribute33"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute34")) {
                this.MSExchExtensionAttribute34 = attributes["msExchExtensionAttribute34"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute35")) {
                this.MSExchExtensionAttribute35 = attributes["msExchExtensionAttribute35"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute36")) {
                this.MSExchExtensionAttribute36 = attributes["msExchExtensionAttribute36"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute37")) {
                this.MSExchExtensionAttribute37 = attributes["msExchExtensionAttribute37"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute38")) {
                this.MSExchExtensionAttribute38 = attributes["msExchExtensionAttribute38"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute39")) {
                this.MSExchExtensionAttribute39 = attributes["msExchExtensionAttribute39"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute40")) {
                this.MSExchExtensionAttribute40 = attributes["msExchExtensionAttribute40"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute41")) {
                this.MSExchExtensionAttribute41 = attributes["msExchExtensionAttribute41"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute42")) {
                this.MSExchExtensionAttribute42 = attributes["msExchExtensionAttribute42"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute43")) {
                this.MSExchExtensionAttribute43 = attributes["msExchExtensionAttribute43"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute44")) {
                this.MSExchExtensionAttribute44 = attributes["msExchExtensionAttribute44"][0].ToString();
            }
            if (attributes.ContainsKey("msExchExtensionAttribute45")) {
                this.MSExchExtensionAttribute45 = attributes["msExchExtensionAttribute45"][0].ToString();
            }

            this.MSExchExtensionCustomAttribute1 = ADDataAccess.GetMultiValuedAttribute<string>("msExchExtensionCustomAttribute1", attributes);
            this.MSExchExtensionCustomAttribute2 = ADDataAccess.GetMultiValuedAttribute<string>("msExchExtensionCustomAttribute2", attributes);
            this.MSExchExtensionCustomAttribute3 = ADDataAccess.GetMultiValuedAttribute<string>("msExchExtensionCustomAttribute3", attributes);
            this.MSExchExtensionCustomAttribute4 = ADDataAccess.GetMultiValuedAttribute<string>("msExchExtensionCustomAttribute4", attributes);
            this.MSExchExtensionCustomAttribute5 = ADDataAccess.GetMultiValuedAttribute<string>("msExchExtensionCustomAttribute5", attributes);
        } 
        #endregion
    }
}
